/** 
 *  @file
 *  @brief   十字形（CROSS）梁截面属性使用解析公式计算类
 *  @author  duweixing
 *  @date    2024.04.23
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#include "CrossSectionFormulaCalculator.h"
#include "DataStructure/Common/Real.h"

using SG::DataStructure::Common::Real;
using SG::DataStructure::FEM::PBARLData;
using SG::DataStructure::FEM::PBARData;
using SG::FEMSolver::Element::CrossSectionFormulaCalculator;

void CrossSectionFormulaCalculator::Compute
(
const SG::DataStructure::FEM::PBARLData& section,
_OUT SG::DataStructure::FEM::PBARData&   property,
_OUT SG::Algebra::Point&                 centroid
) const
{
    Real b0{section.m_dimension[0] * 0.5};
    Real t1{section.m_dimension[1]};
    Real h{section.m_dimension[2]};
    Real t2{section.m_dimension[3]};

    property.m_id  = section.m_id;
    property.m_mId = section.m_mId;
    property.m_A   = h * t1 + 2.0 * b0 * t2;
    // Real yS = 0.0;
    // Real zS = 0.0;
    // Real yC = 0.0;
    // Real zC = 0.0;
    property.m_I1  = (t1 * h * h * h + 2.0 * b0 * t2 * t2 * t2) / 12.0;
    property.m_I2  = h * t1 * t1 * t1 / 12.0 + (t2 * b0 * b0 * b0 / 12.0 + t2 * b0 * (t1 + b0) * (t1 + b0) * 0.25) * 2.0;
    property.m_I12 = 0.0;
    property.m_J   = (h * t1 * t1 * t1 + 2.0 * b0 * t2 * t2 * t2) / 3.0;
    property.m_K1  = h * t1 / property.m_A;
    property.m_K2  = (2.0 * b0 + t1) * t2 / property.m_A;
    property.m_NSM = section.m_nsm;
    property.m_FE  = 0.0;
    property.SetStressPoints ({ 0.5 * h,  0.0,
                                0.0,      0.5 * t1 + b0,
                               -0.5 * h,  0.0,
                                0.0,     -(0.5 * t1 + b0)});
    centroid.m_x = 0.0;
    centroid.m_y = 0.0;
    centroid.m_z = 0.0;
}